import { Pressable, StyleSheet } from 'react-native'
import OwlModal from '../component/common/owlModal'
import { useEffect, useState } from 'react'

export default function Modal({ navigation, route }: any) {
  const params = route.params || { type: 'info', message: 'Error' }
  const [visible, setVisible] = useState(false)
  function back() {
    navigation.goBack()
    params.onClose && params.onClose()
  }
  useEffect(() => {
    setVisible(true)
  }, [])
  return (
    <Pressable onPress={back} style={style.container}>
      <OwlModal
        visible={visible}
        title={params.message}
        autoCloseTime={2000}
        onClose={back}
      />
    </Pressable>
  )
}
const style = StyleSheet.create({
  container: {
    width: '100%',
    height: '100%',
    backgroundColor: 'rgba(0,0,0,0)',
    display: 'flex',
    alignItems: 'center',
    justifyContent: 'center',
  },
})
